<template>
  <view class="mine">
    <!-- 我的 -->
    <view class="head">
      <view class="head-top">
        <view style="display: flex;" v-if="islogin">
          <image class="photo" :src="userinfo.avatar" mode=""></image>
          <view class="person" v-if="islogin">
            <view class="p-name" v-if="maininfo.user">
              {{ maininfo.user.truename }}
            </view>
            <view class="p-id" v-if="maininfo.user">
              用戶ID：{{ maininfo.user.user_id }}
            </view>
            <view class="p-xinxi" v-if="maininfo.user">
              <view class="xinxi-geren">
                <image src="@/static/images/label_grade.png" mode=""></image>
                優惠等級：{{ maininfo.user.name }}
              </view>
              <view style="width: 0rpx;height: 18rpx;border: 1px solid #D6D7DB;margin: 0 5rpx;">
              </view>
              <view class="xinxi-geren">
                <image src="@/static/images/label_integral.png" mode=""></image>
                積分：{{ maininfo.user.score }}
              </view>
            </view>
          </view>
        </view>
        <view style="display: flex;align-items: center;" v-if="!islogin">
          <image class="photo" src="" mode=""></image>
          <view class="btn" @click="tologin">
            登录
          </view>
        </view>
<!--        <u-icon  v-if="islogin" size="28rpx" name="arrow-right" @click="toUrl('/pages/mine/setting/index')">-->
<!--        </u-icon>-->
        <view  v-if="islogin"  @click="toUrl('/pages/mine/setting/index')"  style="width: 40rpx;display: flex;align-items: center;justify-content: center">
          <image style="width: 32rpx;height: 32rpx;" src="@/static/images/rightjiantou .png"></image>
        </view>
      </view>
      <view class="head-bottom">
        <u-row justify="space-between">
          <u-col span="3">
            <view class="demo-layout" @click="toCollect">
              <view class="num">
                {{ maininfo.order&&islogin ? maininfo.order.collection : 0 }}
              </view>
              <view class="item">
                我的收藏
              </view>
            </view>
          </u-col>
          <u-col span="3">
            <view class="demo-layout " @click="tomyGoods">
              <view class="num">
                {{ mygoodsnum&&islogin ? mygoodsnum : 0 }}
              </view>
              <view class="item">
                我的商品
              </view>
            </view>
          </u-col>
          <u-col span="3">
            <view class="demo-layout " @click="toOrder('')">
              <view class="num">
                {{ maininfo.order&&islogin ? maininfo.order.mine_order : 0 }}
              </view>
              <view class="item">
                訂單数
              </view>
            </view>
          </u-col>
          <u-col span="3">
            <view class="demo-layout " @click="topaystatus('')">
              <view class="num">
                {{ maininfo.order&&islogin ? maininfo.order.other_order : 0 }}
              </view>

              <view class="item" >
                子賬戶訂單数
              </view>
            </view>
          </u-col>
        </u-row>
      </view>
    </view>
    <view style="width: 750rpx;height: 16rpx;background: #F5F6F9;opacity: 1;border-radius: 0rpx;">
    </view>
    <view class="order" v-if="power.includes(0) || power.includes(11) || power.includes(111)">
      <view class="my-order">
        <view class="title">
          我的訂單
        </view>
        <u-icon size="28rpx" name="arrow-right" @click="toOrder('')"></u-icon>
      </view>
      <view class="order-bottom">
        <u-row justify="space-between">
          <u-col span="2.4">
            <view class="demo-layout " @click="toOrder(1)">
              <image class="img" src="@/static/images/order_pending-approval.png" mode=""></image>
              <view class="bottom-text">
                未審批
              </view>
            </view>
          </u-col>
          <u-col span="2.4">
            <view class="demo-layout " @click="toOrder(2)">
              <image class="img" src="@/static/images/order_approved.png" mode=""></image>
              <view class="bottom-text">
                已審批
              </view>
            </view>
          </u-col>
          <u-col span="2.4">
            <view class="demo-layout " @click="toOrder(3)">
              <image class="img" src="@/static/images/order_cancel.png" mode=""></image>
              <view class="bottom-text">
                全單取消
              </view>
            </view>
          </u-col>
          <u-col span="2.4">
            <view class="demo-layout " @click="toOrder(4)">
              <image class="img" src="@/static/images/order_modify.png" mode=""></image>
              <view class="bottom-text">
                申請修改
              </view>
            </view>
          </u-col>
          <u-col span="2.4">
            <view class="demo-layout " @click="toOrder(6)">
              <image class="img" src="@/static/images/order_return-goods.png" mode=""></image>
              <view class="bottom-text">
                申請退貨
              </view>
            </view>
          </u-col>
        </u-row>
      </view>
    </view>

    <view style="width: 750rpx;height: 16rpx;background: #F5F6F9;opacity: 1;border-radius: 0rpx;">
    </view>
    <view class="order" v-if="power.includes(0) || power.includes(12)|| power.includes(111)">
      <view class="my-order">
        <view class="title">
          支付状态
        </view>
        <u-icon size="28rpx" name="arrow-right" @click="topaystatus('')"></u-icon>
      </view>
      <view class="order-bottom">
        <u-row justify="space-between">
          <u-col span="2.4">
            <view class="demo-layout " @click="topaystatus('')">
              <image class="img" src="@/static/images/order_all.png" mode=""></image>
              <view class="bottom-text">
                全部訂單
              </view>
            </view>
          </u-col>
          <u-col span="2.4">
            <view class="demo-layout" @click="topaystatus(1)">
              <image class="img" src="@/static/images/order_topaid.png" mode=""></image>
              <view class="bottom-text">
                待支付
              </view>
            </view>
          </u-col>
          <u-col span="2.4">
            <view class="demo-layout " @click="topaystatus(2)">
              <image class="img" src="@/static/images/Partial payall.png" mode=""></image>
              <view class="bottom-text">
                全數支付
              </view>
            </view>
          </u-col>
          <u-col span="2.4">
            <view class="demo-layout " @click="topaystatus(3)">
              <image class="img" src="@/static/images/order_paypart.png" mode=""></image>
              <view class="bottom-text">
                部分支付
              </view>
            </view>
          </u-col>
          <u-col span="2.4">
            <view class="demo-layout ">
            </view>
          </u-col>
        </u-row>
      </view>
    </view>
    <view style="width: 750rpx;height: 16rpx;background: #F5F6F9;opacity: 1;border-radius: 0rpx;">
    </view>
    <view class="mine-bottom">
      <!-- 报价车临时 -->
      <view v-if="power.includes(0) || power.includes(18) || power.includes(111)" class="table" @click="toqunta">
        <image class="img" src="@/static/images/t11292.png" mode=""></image>
        <view class="text">
          報價車
        </view>
      </view>
      <view v-if="power.includes(0) || power.includes(19) || power.includes(111)" class="table"
            @click="toquntationoCar">
        <image class="img" src="@/static/images/t11292.png" mode=""></image>
        <view class="text">
          報價車訂單
        </view>
      </view>
      <view v-if="power.includes(0) || power.includes(13)|| power.includes(111)" class="table" @click="togather">
        <image class="img" src="@/static/images/mine_order-summary.png" mode=""></image>
        <view class="text">
          訂單月匯總
        </view>
      </view>
      <view v-if="power.includes(0) || power.includes(14)" class="table" @click="todata">
        <image class="img" src="@/static/images/mine_analysis.png" mode=""></image>
        <view class="text">
          數據分析
        </view>
      </view>
      <view v-if="power.includes(0) || power.includes(15)" class="table" style="border-bottom:none" @click="todownload">
        <image class="img" src="@/static/images/mine_order-dowload.png" mode=""></image>
        <view class="text">
          月結單下載
        </view>
      </view>
    </view>
<!--    <view class="" style="height: 144rpx;"></view>-->

  </view>
</template>

<script>
import {
  mapState,
  mapGetters,
  mapMutations,
  mapActions
} from 'vuex'
import {getPowers} from "@/network/api/user";

export default {
  data() {
    return {
      // power: []
    };
  },
  onLoad() {
    // this.getPower()
  },
  onShow() {
    // this.getPower()
    this.getMainInfo()
  },
  computed: {
    ...mapState({
      islogin: state => state.user.islogin,
      company: state => state.user.company,
      userinfo: state => state.user.userinfo,
      maininfo: state => state.user.maininfo,
      mygoodsnum: state => state.user.mygoodsnum,
      power: state => state.user.power
    })
  },
  methods: {
    ...mapActions(['getCenterMainInfo']),
    // async getPower() {
    //   const res = await getPowers();
    //   this.power = res.data.power
    // },
    getMainInfo() {
      if (this.islogin) {
        this.getCenterMainInfo()
      }
    },
    tologin() {
      uni.navigateTo({
        url: '/pages/login/index'
      })
    },
    todownload() {
      uni.navigateTo({
        url: '/pages/mine/download/index'
      })
    },
    toqunta() {
      uni.navigateTo({
        url: "/pages/quotacar/index"
      })
    },
    toquntationoCar() {
      uni.navigateTo({
        url: '/pages/mine/quotationCar/index'
      })
    },
    topaystatus(indextab) {
      uni.navigateTo({
        url: `/pages/mine/paystatus/index?indextab=${indextab}`
      })
    },
    toOrder(indextab) {
      uni.navigateTo({
        url: `/pages/mine/order/index?indextab=${indextab}`
      })
    },
    todata() {
      uni.navigateTo({
        url: '/pages/mine/data/index'
      })
    },
    togather() {
      uni.navigateTo({
        url: '/pages/mine/gather/index'
      })
    },
    toCollect() {
      uni.navigateTo({
        url: '/pages/mine/collect/index'
      })
    },
    tomyGoods() {
      uni.navigateTo({
        url: '/pages/mine/mygoods/index'
      })
    },
    toUrl(url) {
      uni.navigateTo({
        url: url
      })
    }
  }
  // methods:{
  // 	toRegister(url){
  // 		uni.navigateTo({
  // 		 url:url
  // 		})
  // 	}
  // }
}
</script>

<style lang="scss">
.mine {
  background-color: #F5F6F9;
  width: 100%;
  height: 100vh;

  .head {

    background: #FFFFFF;

    .head-top {
      margin-top: 160rpx;
      display: flex;
      justify-content: space-between;
      padding: 0 33rpx;

      .btn {
        margin-left: 30rpx;
        width: 200rpx;
        height: 80rpx;
        text-align: center;
        background: #645AED;
        line-height: 80rpx;
        border: 1px solid #CBCBCB;
        border-radius: 28rpx;
        font-size: 32rpx;
        font-family: PingFang SC;
        font-weight: 500;
        color: #FFFFFF;
      }

      .photo {
        width: 144rpx;
        height: 144rpx;
        background: #E5E7FA;
        border-radius: 50%;
        margin-right: 23rpx;
      }

      .person {
        display: flex;
        flex-direction: column;
        justify-content: space-between;

        .p-name {
          font-size: 34rpx;
          font-family: PingFang SC;
          font-weight: bold;
        }

        .p-id {
          font-size: 20rpx;
          font-family: PingFang SC;
          font-weight: 500;
          color: #87889F;
        }

        .p-xinxi {
          height: 40rpx;
          background: #E7E9F8;
          border-radius: 19rpx;
          font-size: 18rpx;
          font-family: PingFang SC;
          padding: 0 15rpx;
          color: #707070;
          display: flex;
          align-items: center;
          justify-content: center;

          .xinxi-geren {
            display: flex;
            align-items: center;

            image {
              height: 30rpx;
              width: 30rpx;
              margin: 0 5rpx;
            }
          }
        }
      }
    }

    .head-bottom {
      margin-top: 55rpx;

      .demo-layout {
        height: 126rpx;
        text-align: center;

        .num {
          font-size: 38rpx;
          font-family: PingFang SC;
          font-weight: bold;
          color: #222222;
          line-height: 43rpx;
        }

        .item {
          font-size: 24rpx;
          font-family: PingFang SC;
          font-weight: 500;
          color: #999999;
        }
      }
    }
  }

  .order {

    background: #FFFFFF;
    padding: 33rpx;

    .my-order {
      display: flex;
      align-items: center;
      justify-content: space-between;

      .title {
        font-size: 32rpx;
        font-family: PingFang SC;
        font-weight: bold;
        color: #333333;
      }
    }

    .order-bottom {
      margin-top: 33rpx;

      .demo-layout {
        text-align: center;

        .img {
          width: 48rpx;
          height: 48rpx;
        }

        .bottom-text {
          font-size: 24rpx;
          font-family: PingFang SC;
          font-weight: 500;
          line-height: 43rpx;
          color: #333333;
        }
      }

    }
  }

  .mine-bottom {
    background: #FFFFFF;
    padding: 0 44rpx;

    .table {
      padding: 32rpx 0;
      display: flex;
      align-items: center;
      border-bottom: 1rpx solid #DEDEDE;

      .img {
        margin-right: 20rpx;
        width: 40rpx;
        height: 40rpx;
      }

      .text {
        font-size: 28rpx;
        font-family: PingFang SC;
        font-weight: 500;
        line-height: 43rpx;
        color: #333333;
      }
    }
  }
}
</style>
